home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Includes_and_Autodocs_3.5 / include / intuition / classes.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-20  |  3.5 KB  |  116 lines

  1. #ifndef    INTUITION_CLASSES_H
  2. #define INTUITION_CLASSES_H
  3. /*
  4. **  $VER: classes.h 40.0 (15.2.1994)
  5. **  Includes Release 44.1
  6. **
  7. **  Used only by class implementors
  8. **
  9. **  (C) Copyright 1989-1999 Amiga, Inc.
  10. **        All Rights Reserved
  11. */
  12.  
  13. /*****************************************************************************/
  14.  
  15. #ifndef    EXEC_TYPES_H
  16. #include <exec/types.h>
  17. #endif
  18.  
  19. #ifndef    EXEC_LIBRARIES_H
  20. #include <exec/libraries.h>
  21. #endif
  22.  
  23. #ifndef UTILITY_HOOKS_H
  24. #include <utility/hooks.h>
  25. #endif
  26.  
  27. #ifndef    INTUITION_CLASSUSR_H
  28. #include <intuition/classusr.h>
  29. #endif
  30.  
  31. /*****************************************************************************/
  32. /***************** "White Box" access to struct IClass ***********************/
  33. /*****************************************************************************/
  34.  
  35. /* This structure is READ-ONLY, and allocated only by Intuition */
  36. typedef struct IClass
  37. {
  38.     struct Hook         cl_Dispatcher;        /* Class dispatcher */
  39.     ULONG         cl_Reserved;        /* Must be 0  */
  40.     struct IClass    *cl_Super;        /* Pointer to superclass */
  41.     ClassID         cl_ID;            /* Class ID */
  42.  
  43.     UWORD         cl_InstOffset;        /* Offset of instance data */
  44.     UWORD         cl_InstSize;        /* Size of instance data */
  45.  
  46.     ULONG         cl_UserData;        /* Class global data */
  47.     ULONG         cl_SubclassCount;    /* Number of subclasses */
  48.     ULONG         cl_ObjectCount;    /* Number of objects */
  49.     ULONG         cl_Flags;
  50.  
  51. } Class;
  52.  
  53. #define    CLF_INLIST    0x00000001L
  54.     /* class is in public class list */
  55.  
  56. /*****************************************************************************/
  57.  
  58. /* add offset for instance data to an object handle */
  59. #define INST_DATA(cl,o)        ((void *)(((UBYTE *)o)+cl->cl_InstOffset))
  60.  
  61. /*****************************************************************************/
  62.  
  63. /* sizeof the instance data for a given class */
  64. #define SIZEOF_INSTANCE(cl)    ((cl)->cl_InstOffset + (cl)->cl_InstSize \
  65.             + sizeof (struct _Object))
  66.  
  67. /*****************************************************************************/
  68. /***************** "White box" access to struct _Object **********************/
  69. /*****************************************************************************/
  70.  
  71. /* We have this, the instance data of the root class, PRECEDING the "object".
  72.  * This is so that Gadget objects are Gadget pointers, and so on.  If this
  73.  * structure grows, it will always have o_Class at the end, so the macro
  74.  * OCLASS(o) will always have the same offset back from the pointer returned
  75.  * from NewObject().
  76.  *
  77.  * This data structure is subject to change.  Do not use the o_Node embedded
  78.  * structure. */
  79. struct _Object
  80. {
  81.     struct MinNode     o_Node;
  82.     struct IClass    *o_Class;
  83.  
  84. };
  85.  
  86. /*****************************************************************************/
  87.  
  88. /* convenient typecast    */
  89. #define _OBJ(o)            ((struct _Object *)(o))
  90.  
  91. /* get "public" handle on baseclass instance from real beginning of obj data */
  92. #define BASEOBJECT(_obj)    ((Object *)(_OBJ(_obj)+1))
  93.  
  94. /* get back to object data struct from public handle */
  95. #define _OBJECT(o)        (_OBJ(o) - 1)
  96.  
  97. /* get class pointer from an object handle    */
  98. #define OCLASS(o)        ((_OBJECT(o))->o_Class)
  99.  
  100. /*****************************************************************************/
  101.  
  102. /* BOOPSI class libraries should use this structure as the base for their
  103.  * library data.  This allows developers to obtain the class pointer for
  104.  * performing object-less inquiries. */
  105. struct ClassLibrary
  106. {
  107.     struct Library     cl_Lib;    /* Embedded library */
  108.     UWORD         cl_Pad;    /* Align the structure */
  109.     Class        *cl_Class;    /* Class pointer */
  110.  
  111. };
  112.  
  113. /*****************************************************************************/
  114.  
  115. #endif
  116.